package com.ly.aicode.core.saver;

import com.ly.aicode.ai.model.HtmlCodeResult;
import com.ly.aicode.ai.model.MultiFileCodeResult;
import com.ly.aicode.model.enums.CodeGenTypeEnum;

import java.io.File;

/**
 * @author luyi
 * @date 2025/11/9 0:20
 */
public class CodeFileSaverExecutor {
    private static final HtmlCodeFileSaveTemplate htmlCodeFileSaveTemplate = new HtmlCodeFileSaveTemplate();
    private static final MultiCodeFileSaveTemplate multiCodeFileSaveTemplate = new MultiCodeFileSaveTemplate();

    public static File executeSave(Object result, CodeGenTypeEnum genTypeEnum) {
        return switch (genTypeEnum) {
            case HTML -> htmlCodeFileSaveTemplate.saveCode((HtmlCodeResult) result);
            case MULTI_FILE -> multiCodeFileSaveTemplate.saveCode((MultiFileCodeResult) result);
            default -> throw new RuntimeException("不支持的文件类型");
        };
    }
}
